﻿<UserControl x:Class="WeatherReport.UserSettingsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="240" d:DesignWidth="240">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
        <Style TargetType="{x:Type Image}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UIElement}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                    <Setter Property="Opacity" Value="0.3"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    
    <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Bottom" 
                Background="White" Opacity="0.8">
        <Label VerticalAlignment="Top" HorizontalAlignment="Left">Country</Label>
        <ComboBox VerticalAlignment="Top" Height="23"
                      DisplayMemberPath="DisplayName" 
                      ItemsSource="{Binding Regions}" SelectedItem="{Binding Path=SelectedRegion, Mode=TwoWay}" />
        <Label HorizontalAlignment="Left" Width="120" Height="28">City</Label>
        <ComboBox Height="23" VerticalAlignment="Top" 
                      ItemsSource="{Binding Cities}" SelectedItem="{Binding Path=SelectedCity, Mode=TwoWay}"
                      Visibility="{Binding Path=IsCityListAvailable, Converter={StaticResource BooleanToVisibility}}" />
        <Label VerticalAlignment="Top" HorizontalAlignment="Left" Height="23" Padding="6,2"
                   Content="{Binding CityListRetrievalErrorMessage}" FontWeight="Bold" Foreground="#E55B49"
                   Visibility="{Binding Path=IsCityListUnavailable, Converter={StaticResource BooleanToVisibility}}"/>

        <Grid Margin="0,8,0,4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="10" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Button Grid.Column="0" HorizontalAlignment="Right"
                        Command="{Binding SettingsOkCommand}">
                <Image Source="Resources/Checkmark.png" Width="13" Height="13" />
            </Button>
            <Button Grid.Column="2" HorizontalAlignment="Left"
                        Command="{Binding SettingsCancelCommand}">
                <Image Source="Resources/X.png" Width="13" Height="13" />
            </Button>
        </Grid>
    </StackPanel>
</UserControl>
